Skip to content

[Alerting v2] Fix rule preview error in alerting_v2 due to missing EUI theme context#261476

Merged
benakansara merged 1 commit into
elastic:mainfrom
benakansara:fix/rule-preview-error
Apr 7, 2026
Merged

[Alerting v2] Fix rule preview error in alerting_v2 due to missing EUI theme context#261476
benakansara merged 1 commit into
elastic:mainfrom
benakansara:fix/rule-preview-error

Conversation

@benakansara
Copy link
Copy Markdown
Contributor

Resolves #260954

Summary

  • Fixes Cannot read properties of undefined (reading 'font') error when rendering the Lens chart in the alerting_v2 rule preview
  • Wraps both app mount functions with coreStart.rendering.addContext() to provide the EUI theme (and other Kibana global context) to the React tree

Root Cause

The alerting_v2 app mounts via ReactDOM.render() which creates a standalone React tree without any EUI ThemeProvider. When Lens renders its embeddable chart inside the rule preview, lnsNumericFontStyles reads euiTheme.font.family (PR: #251576) from Emotion's theme context which is undefined without the provider, causing the error.

Testing

  • Open alerting_v2 rule form and trigger a rule preview with an ES|QL query that renders a Lens chart
  • Verify the chart renders without errors
  • Verify notification policies page still loads correctly

Screenshots

Screenshot 2026-04-07 at 10 21 24 AM

@benakansara benakansara self-assigned this Apr 7, 2026
@benakansara benakansara added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Apr 7, 2026
@github-actions github-actions Bot added the author:actionable-obs PRs authored by the actionable obs team label Apr 7, 2026
@benakansara benakansara marked this pull request as ready for review April 7, 2026 08:23
@benakansara benakansara requested a review from a team as a code owner April 7, 2026 08:23
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Apr 7, 2026

Approvability

Verdict: Would Approve

This is a straightforward bug fix that adds missing EUI theme context by wrapping React components with coreStart.rendering.addContext(). The author owns all changed files, the changes are small and self-contained, and the fix follows a standard React context pattern.

Macroscope would have approved this PR. A repo admin can enable approvability here.

@yiannisnikolopoulos yiannisnikolopoulos self-assigned this Apr 7, 2026
@benakansara benakansara enabled auto-merge (squash) April 7, 2026 09:02
@benakansara benakansara merged commit fc06790 into elastic:main Apr 7, 2026
30 checks passed
kelvtanv pushed a commit to kelvtanv/kibana that referenced this pull request Apr 7, 2026
…I theme context (elastic#261476)

Resolves elastic#260954

### Summary

- Fixes `Cannot read properties of undefined (reading 'font')` error
when rendering the Lens chart in the alerting_v2 rule preview
- Wraps both app mount functions with `coreStart.rendering.addContext()`
to provide the EUI theme (and other Kibana global context) to the React
tree

### Root Cause

The alerting_v2 app mounts via ReactDOM.render() which creates a
standalone React tree without any EUI ThemeProvider. When Lens renders
its embeddable chart inside the rule preview, `lnsNumericFontStyles`
reads `euiTheme.font.family` (PR:
elastic#251576) from Emotion's theme
context which is undefined without the provider, causing the error.

### Testing

- Open alerting_v2 rule form and trigger a rule preview with an ES|QL
query that renders a Lens chart
- Verify the chart renders without errors
- Verify notification policies page still loads correctly

### Screenshots

<img width="1234" height="781" alt="Screenshot 2026-04-07 at 10 21
24 AM"
src="https://github.com/user-attachments/assets/9375415e-8aae-493a-b8c3-006db48333ca"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:actionable-obs PRs authored by the actionable obs team backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Alerting v2] Error in rule preview

4 participants